import request from './request.js'
import { ensureConfigInitialized, serviceUrl } from '../config/config.js'
import log from '../logger.js'

export async function makeVideo(param) {
  // 确保配置初始化完成
  await ensureConfigInitialized();

  const http_url = serviceUrl.face2face
  log.debug('~ makeVideo ~ param:', JSON.stringify(param))
  return request.post(`${http_url}/submit`, param)
}

export async function getVideoStatus(taskCode) {
  // 确保配置初始化完成
  await ensureConfigInitialized();

  const http_url = serviceUrl.face2face
  return request.get(`${http_url}/query?code=${taskCode}`).then((res) => {
    log.debug('~ getVideoStatus ~ res:', JSON.stringify(res))
    return res
  })
}
